import { getLogger } from '@gnlab/utils'
import config from '@/config'

const logger = getLogger('asset-url')

export default function formatAssetUrl<T extends string | null | undefined>(rawURL: T) {
  if (typeof rawURL !== 'string') {
    logger.warn('不合法的 URL', rawURL)
    return rawURL
  }
  return rawURL.startsWith('http') ? rawURL : `${config.ASSET_PREFIX}${rawURL}`
}
